import { createStore, Store } from "vuex";
import { ref, onMounted, computed, watch } from "vue";
import { customApi } from "@/api/api";
import "@/mock/index";
export interface State {
  num: number;
  custom: Array<any>;
  routerUrl: string;
}
const store = createStore<State>({
  state: {
    num: 1,
    // 顾客信息
    custom: [],
    routerUrl: "",
  },
  mutations: {
    updateCustom(state: State, payload) {
      state.custom = payload;
    },
    modifyUrl(state: State, payload) {
      state.routerUrl = payload;
    },
  },
  actions: {
    getCustom: ({ commit }, payload) => {
      return new Promise((resolve) => {
        customApi({ data: "data1" }).then((res) => {
          commit("updateCustom", res);
          resolve(res);
        });
      });
    },
  },
});
export default store;
